#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/17
# @Author  : LiJun
# @Email   : lijun@tianyancha.com
# @Version : 1.0.0

import requests


def get_token():
    corpid = "ww93639de5a29dddfe"
    corpsecret = "W3r0W5XLkP4P3iOF8sCarAbuKVH7lkbJ-3oZJH7blzI"
    url = f"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpid}&corpsecret={corpsecret}"
    r = requests.get(url)
    return r.json().get('access_token', None)


def get_address_book_title_list(token):
    url = f"https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token={token}"
    r = requests.get(url)
    print(r.json())


if __name__ == '__main__':
    get_address_book_title_list(token=get_token())
